import { Component, OnInit, ViewChild, ElementRef } from "@angular/core";
import antlr4 from "antlr4";
import { PL00Lexer } from "../../antlr/PL00Lexer";
import { PL00Parser } from "../../antlr/PL00Parser";
import { PL00InterpretVistorFactory } from "../../interpreter/PL00InterpretVisitor";
import { Pl00EditorComponent } from "../pl00-editor/pl00-editor.component";
import { PL00Error } from "../pl00-editor/PL00Error";
import { Pl00ProblemsPanelComponent } from "../pl00-problems-panel/pl00-problems-panel.component";
import { Pl00ConsoleComponent } from "../pl00-console/pl00-console.component";

@Component({
  selector: "app-pl00-editor-page",
  templateUrl: "./pl00-editor-page.component.html",
  styleUrls: ["./pl00-editor-page.component.css"],
})
export class Pl00EditorPageComponent implements OnInit {
  // 子组件
  @ViewChild(Pl00EditorComponent) editor: Pl00EditorComponent;
  @ViewChild(Pl00ProblemsPanelComponent)
  problemsPanel: Pl00ProblemsPanelComponent;
  @ViewChild(Pl00ConsoleComponent) pl00Console: Pl00ConsoleComponent;

  constructor() {}

  ngOnInit(): void {}

  // 调用编辑器的各种方法
  jumpToLine(error: PL00Error) {
    this.editor.jumpToLine(error);
  }
  run() {
    this.editor.run();
  }
  changeText(str: string) {
    this.editor.inputText = str.split("\n");
    this.editor.validate();
  }
}
